cmake_minimum_required(VERSION 2.8)
project(lua)

if(WIN32)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(WIN32)

set(LUA_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")

#lua static library
file(GLOB LIB_FILES "${LUA_SRC_DIR}/*.c")
message("files ${LIB_FILES}")
list(FILTER LIB_FILES EXCLUDE REGEX "lua.c|luac.c")
message("after filter ${LIB_FILES}")
add_library (lualib STATIC ${LIB_FILES})
target_include_directories(lualib PUBLIC ${LUA_SRC_DIR})
#lua_exe

add_executable(lua "${LUA_SRC_DIR}/lua.c")
target_link_libraries(lua lualib)
if(UNIX)
    target_link_libraries(lua m)
endif(UNIX)

#luac
add_executable(luac "${LUA_SRC_DIR}/luac.c")
target_link_libraries(luac lualib)
if(UNIX)
    target_link_libraries(luac m)
endif(UNIX)

